package com.example.controller.employee;

import com.example.annotation.PassToken;
import com.example.controller.employee.req.AttendanceReq;
import com.example.entity.BO.AttendanceStatisticBO;
import com.example.entity.BO.TimeValueBO;
import com.example.entity.BO.WeekStatiscticBO;
import com.example.service.IEmployeeClockService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ChenXiaoBin
 * on 2020-08-18
 */
@RestController
@RequestMapping("/V1.0/clock")
public class EmployeeController {

    @Autowired
    private IEmployeeClockService employeeClockService;

    @PutMapping(value = "/{employee_id}")
    @PassToken
    @ApiOperation(value = "实现用户打卡功能", notes = "实现用户打卡功能")
    public void clockIn(@PathVariable(value = "employee_id") Integer employeeId) {
        employeeClockService.clockIn(employeeId);
    }

    @PassToken
    @ApiOperation(value = "用户指定月份考勤统计", notes = "用户指定月份考勤统计")
    @GetMapping(value = "")
    public List<AttendanceStatisticBO> attendance(AttendanceReq req) {

        return employeeClockService.attendance(req);
    }

    @PassToken
    @ApiOperation(value = "统计近七天打卡率", notes = "统计近七天打卡率")
    @GetMapping(value = "/week/time_value")
    public List<TimeValueBO> getTimeValue() {
        return employeeClockService.getTimeVale();
    }
}
